﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Details.aspx.vb" Inherits="examquestions.Details" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
    .ratingStar
    {
        font-size: 0pt;
        width: 12px;
        height: 12px;
        cursor: pointer;
        background-repeat: no-repeat;
        display: block;
    }

    .filledRatingStar
    {
        background-image: url(pictures/Star_filled.png);
    }

    .emptyRatingStar
    {
        background-image: url(pictures/Star_empty.png);
    }

    .savedRatingStar
    {
        background-image: url(pictures/Star_saved.png);
    }
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page-header">
        <h2>Question details</h2>
      </div>
<div class="table-responsive">
    <asp:GridView ID="GridView1" class="table table-striped table-hover table-bordered" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="questionID" DataSourceID="SqlDataSource1" Width="100%">
        <Columns>
            <asp:BoundField DataField="questionText" HeaderText="Question" 
                SortExpression="questionText" HtmlEncode="False" 
                HtmlEncodeFormatString="False"/>
            <asp:BoundField DataField="answer" HeaderText="Answer" 
                SortExpression="answer"  HtmlEncode="False" 
                HtmlEncodeFormatString="False"/>
            <asp:ImageField ControlStyle-Width="100px" DataImageUrlField="attachment" HeaderText="Attachment">
<ControlStyle Width="100px"></ControlStyle>
            </asp:ImageField>
        </Columns>
    </asp:GridView>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
        SelectCommand="SELECT * FROM [question] WHERE ([questionID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="questionID" QueryStringField="questionID" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
  

  <div class="row">
        <div class="col-sm-2">
  <!-- Subject -->
    <asp:FormView ID="frm_subject" runat="server" DataSourceID="SqlDataSource1"> 
    <ItemTemplate>Subject: <span class="label label-primary"><%# Eval("subjectID")%> </span></ItemTemplate>
    </asp:FormView>
 </div>
        
        <div class="col-sm-2">
  <!-- Exam board -->
    <asp:FormView ID="frm_examBoard" runat="server" DataSourceID="SqlDataSource1"> 
    <ItemTemplate>Exam board: <span class="label label-primary"><%# Eval("examBoardID")%> </span></ItemTemplate>
    </asp:FormView>
 </div>
 <div class="col-sm-2">
 <!-- Exam type -->
    <asp:FormView ID="frm_examtype" runat="server" DataSourceID="SqlDataSource1"> 
    <ItemTemplate>Exam type: <span class="label label-primary"><%# Eval("examTypeID")%> </span></ItemTemplate>
    </asp:FormView>
</div>
    <div class="col-sm-2">
<!-- Marks -->
    <asp:FormView ID="frm_marks" runat="server" DataSourceID="SqlDataSource1"> 
    <ItemTemplate>Marks: <span class="label label-primary"><%# Eval("pointValue")%> </span></ItemTemplate>
    </asp:FormView>
</div>
<div class="col-sm-2">
<!-- Author -->
    <asp:FormView ID="frm_author" runat="server" DataSourceID="SqlDataSource1"> 
    <ItemTemplate>Author: <span class="label label-primary"><%# Eval("author")%> </span></ItemTemplate>
    </asp:FormView>
</div>
</div>
  
  <!-- Worthy 1 -->
    <div class="page-header">
        <h2>Actions</h2>
      </div>
      <div class="row">
        <div class="col-sm-4">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Like & rate</h3>
            </div>
            <div class="panel-body">
             <asp:LinkButton ID="btn_like" class="btn btn-primary" runat="server" 
                    Text="Like"/>
              
    <br />
    <asp:Label ID="lbl_like" class="alert alert-success" runat="server" Text="You already like this question" 
        Visible="False"></asp:Label>
     <br />
    <asp:SqlDataSource ID="SqlDataSource5" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
        SelectCommand="SELECT Count(likes.author) AS userLikes
FROM likes
WHERE ([likes.questionID] = ?)
GROUP BY likes.questionID;">
        <SelectParameters>
            <asp:QueryStringParameter Name="questionID" QueryStringField="questionID" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
   <br />
   <asp:FormView ID="frm_likes" runat="server" DataSourceID="SqlDataSource5">
    <ItemTemplate>This question has been liked <span class="badge"><%# Eval("userLikes")%></span> time(s).</ItemTemplate>
    </asp:FormView>
    <hr />
    <asp:Label ID="lbl_rate" runat="server" Text=""></asp:Label><br />
    <ajaxToolkit:Rating ID="Rating1" runat="server"
            CurrentRating="0"
            MaxRating="5"
            StarCssClass="ratingStar"
            WaitingStarCssClass="savedRatingStar"
            FilledStarCssClass="filledRatingStar"
            EmptyStarCssClass="emptyRatingStar"
            ReadOnly="False" />
    <br />
    <asp:Button ID="btn_rating" class="btn btn-primary" runat="server" Text="Save Rating" OnClick="btn_rating_click" />
    <br />
    <asp:Label ID="Label1" class="alert alert-success" runat="server" Text="Already rated!"></asp:Label>
    <br />
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
        SelectCommand="SELECT [questionID], [ratingAverage] FROM [ratingAverage] WHERE ([questionID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="questionID" QueryStringField="questionID" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br />
    <asp:FormView ID="frm_ratings" runat="server" DataSourceID="SqlDataSource4">
    <ItemTemplate>This question has received an average rating of <span class="badge"><%# Eval("ratingAverage","{0:n1}")%></ItemTemplate>
    </asp:FormView>
    <asp:FormView ID="frm_ratings_2" runat="server" DataSourceID="SqlDataSource6">
    <ItemTemplate>This question has been rated by <span class="badge"><%# Eval("userRatings")%></span> people.</ItemTemplate>
    </asp:FormView>
            </div>
          </div>

<asp:SqlDataSource ID="SqlDataSource6" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
        SelectCommand="SELECT Count(ratings.author) AS userRatings
FROM ratings
WHERE ([ratings.questionID] = ?)
GROUP BY ratings.questionID;">
        <SelectParameters>
            <asp:QueryStringParameter Name="questionID" QueryStringField="questionID" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

    

        </div><!-- /.col-sm-4 -->
        <div class="col-sm-4">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Report question</h3>
            </div>
            <div class="panel-body">
              
              <a href="mailto:report@examquestions.com?subject=Copyright Infringement" class="btn btn-warning btn-block" role="button">Report copyright infringement</a>
              <br />
              <a href="mailto:report@examquestions.com?subject=Innapropriate Content" class="btn btn-danger btn-block" role="button">Report innapropriate content</a>
              </div>
          </div>
        </div><!-- /.col-sm-4 -->
        <div class="col-sm-4">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">Tags</h3>
            </div>
            <div class="panel-body">
              <asp:CheckBoxList ID="cb_tags" runat="server" DataSourceID="SqlDataSource3" 
         DataTextField="tagBody" DataValueField="tagID">
	     </asp:CheckBoxList>
 	     Add new tags here, separate tags using commas: <asp:TextBox ID="tb_addNewTags" 
                    class="form-control" runat="server" Width="100%"></asp:TextBox><br />
	     <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
	         ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
	         ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
	         SelectCommand="SELECT DISTINCT [tagID], [tagBody] FROM [tag]"></asp:SqlDataSource>
	     <asp:Button ID="btn_addTag" class="btn btn-primary" runat="server" Text="Add Tag(s)" />
            </div>
          </div>
        </div><!-- /.col-sm-4 -->
      </div>
  
    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajaxToolkit:ToolkitScriptManager>
    
  <div class="page-header">
        <h2>Comments</h2>
      </div>
    <asp:TextBox ID="tb_commentTitle" runat="server" 
        CssClass="form-control" placeholder="Use comments to help improve this question and/or answer"></asp:TextBox>
    <asp:TextBox ID="tb_commentBody" runat="server" 
        TextMode="MultiLine" Width="100%" Rows="6"></asp:TextBox>
    <ajaxToolkit:HtmlEditorExtender ID="tb_commentBody_HtmlEditorExtender" 
        runat="server" Enabled="True" EnableSanitization="False" 
        TargetControlID="tb_commentBody">
    </ajaxToolkit:HtmlEditorExtender>
    <br />
    <asp:Button ID="btn_submit_comment" class="btn btn-primary" runat="server" Text="Add Your comment" />
    <br />
   
    <br />
    <asp:GridView ID="GridView2" runat="server" 
        AutoGenerateColumns="False" Width="100%" class="table table-striped table-hover table-bordered">
        <Columns>
            <asp:BoundField DataField="commentTitle" HeaderText="Title" 
                SortExpression="commentTitle" />
            <asp:BoundField DataField="commentBody" HeaderText="Comment" 
                SortExpression="commentBody" HtmlEncode="False" HtmlEncodeFormatString="False" />
            <asp:BoundField DataField="Author" HeaderText="Author" 
                SortExpression="Author" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
        SelectCommand="SELECT [commentBody], [commentTitle] FROM [comment] WHERE ([questionID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="questionID" QueryStringField="questionID" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
	     <br />
         <br />
         <br />
         <br />
   
</asp:Content>